
# todo: ==================== 业务数据首日（第一次）同步 ====================


# ======================================================================
#                todo：1.订单详情表：order_detail（增量，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/order_detail/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  order_id,
  sku_id,
  sku_name,
  order_price,
  sku_num,
  create_time,
  source_type,
  source_id,
  split_total_amount,
  split_activity_amount,
  split_coupon_amount
FROM order_detail
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                todo: 2.退单表：order_refund_info（增量，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/order_refund_info/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  user_id,
  order_id,
  sku_id,
  refund_type,
  refund_num,
  refund_amount,
  refund_reason_type,
  refund_status,
  create_time
FROM order_refund_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                todo: 3.订单状态日志表：order_status_log（增量，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/order_status_log/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  order_id,
  order_status,
  operate_time
FROM order_status_log
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#        todo: 4.订单明细活动关联表：order_detail_activity（增量，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/order_detail_activity/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  order_id,
  order_detail_id,
  activity_id,
  activity_rule_id,
  sku_id,
  create_time
FROM order_detail_activity
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#         todo: 5.订单明细购物券表：order_detail_coupon（增量，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/order_detail_coupon/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  order_id,
  order_detail_id,
  coupon_id,
  coupon_use_id,
  sku_id,
  create_time
FROM order_detail_coupon
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'



# ======================================================================
#         todo: 6.商品评论表：comment_info（增量，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/comment_info/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  user_id,
  sku_id,
  spu_id,
  order_id,
  appraise,
  create_time
FROM comment_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


